﻿
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using QDCommon.Model;
namespace QDCommon.Controller
{
    public class BaseController : Microsoft.AspNetCore.Mvc.Controller
    {
        protected string UserName { get; private set; } = "";
        protected long? UserId { get; private set; } = -1;
      
       
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            base.OnActionExecuting(context);
            if (User != null)
            {
                UserName = UserIdentityHelper.GetUserName(User);
                UserId = UserIdentityHelper.GetUserId(User);
            }
        }

        protected IActionResult Succed(object model)
        {
            RequestResult result = new RequestResult() { StateCode = StateCode.RequestSucced, Data = model };
            return Json(result);
        }
        protected IActionResult Error(StateCode code,string message)
        {
            RequestResult result = new RequestResult() { StateCode = code, Message = message };
            return Json(result);
        }
    }
}